<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .div{
            width: 100px;
            height: 100px;
            background-color: greenyellow;
        }
    </style>
</head>
<body>
    <div id="box">
        <div class="red child">1</div>
        <div class="child blue">2</div>
        <div class="child">3</div>
    </div>
    <button onclick="fun()">删除</button>
    <input type="text" id="ipt"/>
    <ul>
    </ul>
    <button id="btn">click</button>
    <input type="text" id="ipt1" onchange="num(this.id)"/>
    <input id="ipt2" onfocus="ff1()" onblur="ff2()"/>
    <div class="div" onmouseover="sum()" onmouseout="sum1()"></div>
    <script>
        function ff1(){
            console.log('获取焦点');
        }
        function ff2(){
            console.log('失去焦点');
        }

        window.onload = function (){

        }
        document.body.onkeydown = function(){
            console.log('按下: ');
        }
        function sum(){
            console.log('移动鼠标');
        }
        function sum1(){
            console.log('移出鼠标');
        }

        let ipt = document.getElementById('ipt');
        ipt.onchange =function(e){
            console.log('e',e.target.value);
        }   

        function num(id){
            console.log(id);
            let ipt = document.getElementById(id);
            let value = ipt.value;
            console.log(value);
        }
        let btn = document.getElementById('btn')
        console.log(btn);
        btn.addEventListener('click', function(){
            console.log('----');
        })
        function funC(){
            console.log('btn===>','funC');
        }
        btn.onclick = funC
        function fun(){
            let p = document.getElementById('box');
            let dele = document.getElementsByClassName('child')[1];
            p.removeChild(dele)
        }
        let add  = document.getElementsByTagName('ul')[0];
        var arr = ['葡萄','哈密瓜','香蕉','梨子','苹果'];
        console.log('ul',add);
            for(var i = 0; i<arr.length; i++){
                let tempLi = document.createElement('li');
                tempLi.innerText = arr[i]
                add.appendChild(tempLi)
            }
    </script>
</body>
</html>